{% extends 'base.html' %}
{% block title %}扫描任务{% endblock %}
{% block subtitle %}任务列表{% endblock %}
{% block javascript %}
<script type="text/javascript" src="{{url_for('static',filename='js/jquery-1.11.0.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/jqueryui/js/jquery-ui-1.10.4.custom.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='js/bootstrap.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/datatables/js/jquery.dataTables.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/datatables/TableTools/js/TableTools.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/datatables/bootstrap/3/dataTables.bootstrap.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='js/datatables.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/customscroll/jquery.mCustomScrollbar.concat.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/jquery-easing/jquery.easing.1.3.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/offlinejs/offline.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='js/script.js')}}"></script>
{% endblock %}
{% block css %}
<link rel="stylesheet" href="{{url_for('static',filename='css/bootstrap.min.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='lib/offlinejs/themes/offline-theme-dark.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='css/bootstrap-override.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='css/font-awesome.min.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='css/layout.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='css/library.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='css/style.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='lib/offlinejs/themes/offline-theme-dark.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='lib/datatables/bootstrap/3/dataTables.bootstrap.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='lib/datatables/TableTools/css/TableTools.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='lib/jquery-fileupload/css/jquery.fileupload.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='lib/jquery-fileupload/css/jquery.fileupload-ui.css')}}">

{% endblock %}
{% block active2 %}class="active"{% endblock %}
{% block content %}
{% for msg in get_flashed_messages() %}
<div class="alert alert-success">
	{{ msg }}
	<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
</div>

{% endfor %}

<div class="row">
			  <div class="col-md-12">
				  	<div class="panel panel-default">
					  <div class="panel-body">
						  <button class="btn btn-success" data-toggle="modal" data-target="#modalform"><i class="fa fa-plus"></i> 新增任务</button>
						  <div style="display:inline-block;">
							  <form  method="post" action="{{url_for('tasks.uploadTarget')}}" enctype="multipart/form-data">
									<div>
										<span class="btn btn-info fileinput-button">
											<i class="fa fa-folder"></i>
											<span>批量导入</span>
											<input class="btn btn-success" type="file" name="file" />
										</span>
										<button type="submit" class="btn btn-primary start">
											<i class="fa fa-cloud-upload"></i>
											<span>提交</span>
										</button>
									</div>
								</form>
						  </div>
							<!-- Modal Form -->
							<div class="modal fade" id="modalform" tabindex="-1" role="dialog" aria-hidden="true">
							   <div class="modal-dialog">
							    <div class="modal-content">
							      <div class="modal-header">
							        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							        <h4 class="modal-title" id="myModalLabel">新增任务</h4>
							      </div>
							      <div class="modal-body" style="margin-bottom:-30px;">
									  <form class="form-horizontal" role="form" action="{{url_for('tasks.addtask')}}" method="POST">
										  <div class="form-group">
											<label  class="col-sm-2 control-label">任务名称</label>
											<div class="col-sm-10">
											  <input type="text" name="targetname" class="form-control" placeholder="任务名称">
											</div>
										 </div>
										  <br>
										  <textarea name="targets" class="form-control" rows="5" placeholder="每行一个URL"></textarea>
										  <div class="modal-footer">
											<button type="submit" class="btn btn-info">提交</button>
										  </div>
										</form>
							      </div>
							    </div>
							  </div>
							</div>
						  

						  <button type="button" class="btn btn-default" id="tooltip-right" data-toggle="tooltip" data-placement="right" title="" data-original-title="批量导入txt文件" style="border:none"><i class="fa fa-ellipsis-h"></i></button>
							<div style="float:right; ">
								<div>
									<a href="{{url_for('tasks.delAllTask')}}"><button class="btn btn-danger" ><i class="fa fa-fire"></i> 清空任务</button></a>
								</div>
						  </div>
						  <br>
						  <br>
					  		<table cellpadding="0" cellspacing="0" border="0"
					  		class="table table-bordered">
									<thead>
									<tr>
										<th>id</th>
										<th>任务名称</th>
										<th>开始时间</th>
										<th>结束时间</th>
										<th>状态</th>
										<th>查看</th>
										<th>删除</th>
									</tr>
								</thead>
								<tbody>
									{% for task in tasks %}
									<tr >
										<td>{{task.id}}</td>
										<td>{{task.name}}</td>
										<td>{{task.starttime}}</td>
										<td>{{task.endtime}}</td>
										{% if task.status=='SUCCESS' %}
										<td><span class="label label-success">{{task.status}}</span></td>
										{% elif task.status=='PENDING'%}
										<td><span class="label label-default">{{task.status}}</span></td>
										{% elif task.status=='STARTED' %}
										<td><span class="label label-primary">{{task.status}}</span></td>
										{% elif task.status=='PROGRESS' %}
										<td><span class="label label-info">{{task.status}}</span></td>
										{% else %}
										<td><span class="label label-danger">{{task.status}}</span></td>
										{% endif %}
										<td><a href="{{url_for('tasks.seetask',id=task.id)}}"><i class="fa fa-sign-in"></i></a></td>
										<td><a href="{{url_for('tasks.deltasks',tid=task.tid)}}"><i class="fa fa-times"></i></a></td>
									</tr>
								{% endfor %}
								</tbody>

							</table>
						  <div style="text-align:center">
								{% import 'pages.html' as pg %}
								{{ pg.my_paginate(pagination,'tasks.tasklist') }}
							</div>

					  </div>
				  	</div>

			  </div>
            </div>


{% endblock %}
